const usePolling = (fn: any, deps: any, delay = 100, ...arg: any) => {
  let check = (dep: any) => {
    return dep && dep !== 'undefined' && dep !== 'null';
  };
  let newFn = () => {
    if (deps.every(check)) {
      setTimeout(() => {
        fn(...arg);
      }, delay);
    } else {
      setTimeout(() => {
        newFn();
      }, delay);
    }
  };
  return newFn();
};

export default usePolling;
